1. Field of the Invention
The present invention relates generally to database management systems. The invention is more particularly related to data management systems and transaction processing systems that utilize a lock manager for protecting database resources from incompatible uses. The invention is still further related to the manner of implementing a database management system which allows the use of nested databases based on computer data structures which are stored in a memory. Moreover, the invention is related and applicable to any system which provides concurrent access to shared data.
2. Discussion of the Background
When two people or entities desire access to information within a database or other location at the same time, or desire to write data into a database related to the same information at or around the same time, there is an inherent conflict and problem which exists. These problems can occur in any type of application where data is shared, and word processing and engineering design are two areas in which such simultaneous access occurs, although this invention is applicable to any setting or situation where there is a desire to use the same data by more than one entity.
In a database management system, ACID (xe2x80x9cAtomicity, Consistency, Isolation, Durabilityxe2x80x9d) properties are desirable.
Atomicity means that either the results of the transaction (i.e., changes to the database) are all properly reflected in the database, or none of them are. Generally, a transaction is said to commit or abort. When a transaction commits, all changes made to the database by the transaction are durably stored, leaving the database in a consistent state. When a transaction aborts, any changes made to the database by the transaction are backed out, once again leaving the database in a consistent state.
Consistency means that each transaction commits only legal results to the database. Thus a transaction must bring the database from one consistent state to another consistent state.
Isolation means that events within a transaction must be hidden from other transactions running concurrently. Concurrent transactions must not interfere with each other. They execute as if they had the database to themselves.
Durability means that once a transaction has been completed and has committed its results to the database, the system must guarantee that these results survive any subsequent malfunctions.
While the above ACID properties are highly desirable, having multiple writers of the same data usually requires a compromise with regard to the ACID properties. It is extremely difficult to ensure transactional properties, and at the same time also allow everyone or each transaction to do whatever he, she or it needs to do, whenever he, she or it would like to. Simply allowing another to access data while the data is in use poses an inherent conflict to the ACID properties.
Accordingly, it is an object of the invention to allow multiple entities to access the same data. It is a further object of the invention to lock the data in a multiuser environment such that, to the extent possible, the ACID properties are maintained. It is yet another object of the invention to have a database management system in which multiple users or entities have access to the data through different databases, which may be referred to as databases, virtual databases, or subdatabases. It is a still further object of the invention to provide a database management system and/or the data structures thereof which allow the implementation of the subdatabases or virtual databases.
These and other objects are accomplished by a memory including data structures, a method, system, and computer program product which allow concurrency control and locking of data in a multiuser environment. For transactions which are in existence, there is an association or reference to a database or subdatabase associated with that transaction. This data structure related to the transaction may be referred to as a transaction control block. Data structures, which are referred to herein as database control blocks, indicate which database or subdatabase relates to a data item. Moreover, there is a data structure related to the actual lock of the data, referred to as a lock control block, and/or a lock request block. The association among the various data structures allows the implementation of the concept of nested databases, subdatabases or virtual databases. For example, the data structure arrangement preferably allows there to be a determination as to the context database of a particular transaction, and also the subdatabases under that transaction. Further, the data structure related to the transaction may also contain references to granted and pending lock requests which may be represented by the data structures relating to locks of the data. The data structures related to the virtual databases, the database control blocks, are referenced by the locking data structures so that it can be determined to which database or subdatabase the lock relates.
In accordance with one embodiment of the invention, there is a memory for storing data for access by a data processing system. This data is not necessarily the data item which the end user ultimately desires, but may be the data related to the data structures indicating the locking and subdatabase information. The memory includes a data structure including information of a transaction. This data structure is preferably implemented as a transaction control block. The memory further includes a data structure including information of a lock of data of the transaction. This data structure may be referred to as a lock control block and/or a lock request block. Further, there is a plurality of data structures including information of a plurality of databases. These data structures related to the databases may be referred to as database control blocks. The database control blocks are utilized to associate a particular database or subdatabase with a lock and transaction, or vice versa, in order to properly control the nested or subdatabases.
The invention also relates to the creation and use of the data structures which implement the concept of the nested databases or subdatabases. A method of indicating that a data item is locked includes the steps of creating in a first hierarchical level, a data structure indicating that the data item is locked by a first transaction associated with the first hierarchical level. Further, the method includes a step of creating, at a second hierarchical level, a data structure indicating that the data item is locked by a second transaction associated with a second hierarchical level. Thus, the above steps create a hierarchy of locking controlled data structures, such as lock control blocks. Each level in the hierarchy may be utilized by a different database, subdatabase, or virtual database.
In order to gain access to a data item, it must first be determined if there is an existing lock on that data item. This may be performed by the steps of (a) determining if a lock for the data item exists at a first hierarchical level, and (b) creating a lock for the data item at the first hierarchical level when step (a) determines that the lock for the data item does not exist. There is a step (c) for determining if a lock for the data item exists at a second level when step (a) determines that the lock for the data item does not exist. Further, there is a step (d) of creating a lock on the data item, when a lock on the data item does not exist at the second hierarchical level.
In addition to the method steps for performing the above functionality, the invention includes a system having various means for carrying out the above functionality. Moreover, the invention still further includes a computer program product including executable instructions for carrying out the methodology of the invention.